<div class="fixed-bar">
    <form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search">
    <div class="layui-form-item">
     <div class="layui-inline">
         <label class="layui-form-label">订单号/采购批号</label>
         <div class="layui-input-inline">
             <input type="text" name="client_ordernum" lay-verify="" placeholder="输入订单号" class="layui-input">
         </div>
     </div>
        {if env('env_site') == 'riwei' }
        <div class="layui-inline">
            <label class="layui-form-label">客户单号</label>
            <div class="layui-input-inline">
                <input type="text" name="ext_id" lay-verify="" placeholder="输入客户单号" class="layui-input">
            </div>
        </div>
        {/if}
     <div class="layui-inline">
     	<label class="layui-form-label">关键字</label>
         <div class="layui-input-inline">
             <input type="text" name="keyword" lay-verify="" placeholder="输入关键字，按回车搜索" class="layui-input">
         </div>
     </div>
     <div class="layui-inline">
     	<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
     </div>
 </div>
    </form>
</div>

<table id="dataTable"></table>

{include file="system@block/layui" /}

<script type="text/html" title="操作按钮模板" id="buttonTpl">
    <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe" hisi-data="{width: '470px', height: '400px'}" title="修改备忘">修改</a>
	<a href="{:url('status')}?id={{ d.id }}&val=-1" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>
</script>

<script type="text/html" id="toolbar">
    <div class="layui-btn-group fl">
        <a href="{:url('add')}" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-add-circle-fine hisi-iframe" hisi-data="{width: '470px', height: '400px'}" title="添加备忘">&nbsp;添加</a>
		<a data-href="{:url('status?val=-1')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon layui-icon-close red">&nbsp;删除</a>
    </div>
</script>

<script type="text/html" id="createTimeTpl">
    <div>{{layui.util.toDateString(d.create_time * 1000) }}</div>
</script>

<script type="text/html" id="statusTpl">
    {{#  if(d.status == 0){ }}
		<div class="status-{{ d.id }}">
			<a href="{:url('status')}?id={{ d.id }}&val=1" class="layui-btn layui-btn-xs layui-btn-danger hisi-ajax" data-id="{{ d.id }}" refresh="false" callback="callbackUpdateStatus">异常</a>
		</div>
	{{#  } else { }}
		<span class="green">已处理</span>
	{{#  } }}
</script>
<script type="text/html" title="订单号/采购批号" id="client_ordernumTpl">
    {{# if (d.stock_m_type==0){ }}
    <span class="copy-item">{{d.client_ordernum}}</span>
    {{# }else { }}
    <span class="copy-item">B{{d.order_material_id}}</span>
    {{# } }}
</script>
<script type="text/javascript">
    layui.use(['table', 'tool'], function() {
        var $ = layui.jquery;
        var table = layui.table;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,limits: [20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,cols: [[ //表头
                {type:'checkbox', fixed:'left'}
                ,{field: 'id', title: '编号', sort: true}
                ,{field: 'client_ordernum', title:'订单号/采购批号'  , templet: '#client_ordernumTpl'}
                ,{field: 'content', title: '内容',width:500}
                ,{field: 'status', title: '状态', templet: '#statusTpl'}
                ,{field: 'create_time', title: '创建时间',templet: '#createTimeTpl'}
                ,{title: '操作', templet: '#buttonTpl', fixed: 'right'}
            ]]
        });
        
        // 异常处理回调
        window.callbackUpdateStatus = function(obj, res) {
        	if (res.code == 1) {
        		var id = obj.attr('data-id');
        		console.log(obj.attr('data-id'));
        		$('.status-'+id).html('<span class="green">已处理</span>');
        	}
        	
        }
    });
</script>